package pir.hillchen.std.mybatis.txmapper.config.datasource;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import pir.hillchen.std.mybatis.txmapper.config.mybaits.MyBatisConfig;

import javax.sql.DataSource;

/**
 * Created by hillchen on 2017/9/28 0028.
 */

@Configuration
@EnableConfigurationProperties(MyBatisConfig.class)
public class DataSourceConfiguration {
    @Bean(name = "dataSource")
    public DataSource createDataSource(MyBatisConfig myBatisConfig){
        /*List<DataSourceConfig> dataSourceConfigs = myBatisConfig.getDataSource();
        return dataSourceConfigs.get(0).createDataSource();*/
        return myBatisConfig.getDatasource().get(0).createDataSource();
    }
}
